Transportation Model milp FICO-Xpress MOSEL short region DISTANCE: array(PLANT,REGION) of real ! Distance of each route plant->region FUELCOST: real ! Fuel cost per unit distance end-declarations ! Read data from file initializations from 'model.dat' DEMAND [PLANTCAP, PLANTCOST] as 'PlantCapCost' [DISTANCE, TRANSCAP] as 'DistTCasp' FUELCOST end-initializations finalize(REGION) ! Turn dynamic sets into static sets finalize(PLANT) ! containing the data read previously. ! All arrays subsequently declared and ! indexed by these sets will therefore ! be static. declarations flow: array(PLANT,REGION) of mpvar ! Amount transported on each route end-declarations ! Objective: minimize total cost MinCost:= sum(p in PLANT,r in REGION) (FUELCOST * DISTANCE(p,r) + PLANTCOST(p)) * flow(p,r) ! Limits on plant capacity forall(p in PLANT) Supply(p):= sum(r in REGION) flow(p,r) <= PLANTCAP(p) ! Satisfy all demands forall(r in REGION) Demand(r):= sum(p in PLANT) flow(p,r) = DEMAND(r) ! Bounds on flows forall(p in PLANT,r in REGION) flow(p,r) <= TRANSCAP(p,r) minimize(MinCost) ! Solve the LP-problem ! Print out the solution declarations rsum: array(REGION) of integer ! Auxiliary data table for printing psum,prsum,ct,iflow: integer ! Counters end-declarations writeln("Product Distribution at Dash Motors") writeln("===================================") writeln("Least cost solution found (Fuel cost = ", strfmt(FUELCOST,0,2),")"); ! Print the solution (product flows) ! in table format writeln("\nProduct Distribution\n--------------------") writeln(strfmt("Sales Region",44)) write(strfmt("",14)) forall(r in REGION) write(strfmt(r,9)) writeln(strfmt("TOTAL",9), " Capacity") ct:=0 forall(p in PLANT) do ct += 1 if ct=2 then write("Plant ",strfmt(p,-8)) else write(" ",strfmt(p,-8)) end-if psum:=0 forall(r in REGION) do iflow:=integer(getsol(flow(p,r))) psum += iflow rsum(r) += iflow if iflow<>0 then write(strfmt(iflow,9)) else write(" ") end-if end-do writeln(strfmt(psum,9), strfmt(integer(PLANTCAP(p)),9)) end-do write("\n", strfmt("TOTAL",-14)) prsum:=0 forall(r in REGION) do prsum += rsum(r); write(strfmt(rsum(r),9)) end-do writeln(strfmt(prsum,9)) write(strfmt("Demand",-14)) forall(r in REGION) write(strfmt(integer(DEMAND(r)),9)) ! Print the reduced costs in table format writeln("\n\nReduced Costs\n-------------") writeln(strfmt("Sales Region",44)) write(strfmt("",14)) forall(r in REGION) write(strfmt(r,9)) writeln ct:=0 forall(p in PLANT) do ct += 1 if ct=2 then write("Plant ",strfmt(p,-8)) else write(" ",strfmt(p,-8)) end-if forall(r in REGION) do dj:= getrcost(flow(p,r)) if (dj <> 0.0) then write(strfmt(dj,9,1)) else write(" ") end-if end-do writeln end-do ! Print objective function value writeln("\n\nTotal cost of distribution = ",strfmt(getobjval/1e6,0,3)," million.\n") end-model]]> ! Data file for 'transprt.mos' DEMAND: [ (Scotland) 2840 (North) 2800 (SWest) 2600 (SEast) 2820 (Midlands) 2750 ] PlantCapCost: [ (Corby) [ 3000 1700 ] (Deeside) [ 2700 1600 ] (Glasgow) [ 4500 2000 ] (Oxford) [ 4000 2100 ] ] DistTCasp: [ (Corby Scotland) [ 0 0 ] (Corby North) [ 400 1000 ] (Corby SWest) [ 400 1000 ] (Corby SEast) [ 300 1000 ] (Corby Midlands) [ 100 2000 ] (Deeside Scotland) [ 500 1000 ] (Deeside North) [ 200 2000 ] (Deeside SWest) [ 200 1000 ] (Deeside SEast) [ 200 1000 ] (Deeside Midlands) [ 400 300 ] (Glasgow Scotland) [ 200 3000 ] (Glasgow North) [ 400 2000 ] (Glasgow SWest) [ 500 1000 ] (Glasgow SEast) [ 900 200 ] (Glasgow Midlands) [ 0 0 ] (Oxford Scotland) [ 800 0 ] (Oxford North) [ 600 2000 ] (Oxford SWest) [ 300 2000 ] (Oxford SEast) [ 200 2000 ] (Oxford Midlands) [ 400 500 ] ] FUELCOST: 17 (!******************************************************* * Mosel Example Problems * * ====================== * * * * file transprt.mos * * ````````````````` * * Example for the use of the Mosel language * * (Transportation model with nicely formatted output) * * * * (c) 2001 Dash Associates * * author: S. Heipcke * *******************************************************!)